package cn.webrx;

import java.util.Map;
import java.util.TreeMap;

public class TreeMap3 {
    public static void main(String[] args) {
        TreeMap<String, String> tree = new TreeMap<>();
        tree.put("1", "zhangsan1");
        tree.put("2", "zhangsan2");
        tree.put("3.1", "zhangsan3");
        tree.put("4", "zhangsan4");

        Map.Entry<String, String> entry = tree.firstEntry();
        System.out.println(entry.getKey()); //1
        System.out.println(entry.getValue());//


        Map.Entry<String, String> stringStringEntry = tree.ceilingEntry("3");
        //获取元素的key
        System.out.println("getKey:" + stringStringEntry.getKey());
        //获取元素的value值
        System.out.println("getValue:" + stringStringEntry.getValue());
    }
}
